#ifndef __H__CYCLE_H__
#define __H__CYCLE_H__

#include "linux_def.h"
#include "core.h"
#include "connection.h"

#define	CYCLE_POOL_SIZE	16384

typedef struct shm_zone_s shm_zone_t;
typedef int(*shm_zone_init_pt)(shm_zone_t *zone, void *data);

struct shm_zone_s{
	void	*data;
	shm_t	shm;
	shm_zone_init_pt init;
	char	*name;
	void	*tag;
};

struct cycle_s{

	log_t	*log;	//	log file
	pool_t		*pool;			//pool for malloc memory


	connection_t	**files;			//save the relation for socket and connection
	connection_t	*free_connections;		// free conneciton pools
	int		free_connection_n;		// the NO.s of the free connections

	array_t		listening;		// listenging 
	list_t		shared_memory;		//list for shared memory
/*
	queue_t		reusable_connections_queue;

*/
	connection_t	*connections;		//all the conneciton list
	int		connection_n;		//pre NO. of conneciton

	event_t		*read_events;		//read event
	event_t		*write_events;		//write event

	char		*conf_file;		//file for configure
};

extern volatile cycle_t *g_cycle;
cycle_t *g_init_cycle(cycle_t *cycle);

#endif
